<div class="wrap">
	<div class="header">
		<span id="return">返回上一级</span>
	</div>
	<ul class="order_list">
		<li>
			<label>订单编号</label>
			<span id="orderNum"></span>
		</li>
		<li>
			<label>印前负责人</label>
			<select id="prePrint"></select>
		</li>
		<li>
			<label>印刷负责人</label>
			<select id="print"></select>
		</li>
		<li>
			<label>印后负责人</label>
			<select id="afterPrint"></select>
		</li>
		<li>
			<label>质检负责人</label>
			<select id="test"></select>
		</li>
		<li>
			<a href="javascript:void(0)" id="orderSubmit">提交</a>
		</li>
	</ul>
</div>
<script>
	//用cookie获取id
	var id = $.cookie("id");
	$("#orderNum").text(id);
	//返回上一级
	$("#return").on("click",function(){
		$("#main").empty();
		$.ajax({
			type:"get",
			url:"product_list_detail.html",
			success:function(res){
				$("#main").append(res);
			}
		});
	})
	//工序单人员
	$.ajax({
		type:"post",
		url:"http://39.108.164.20/device/SysUser/SelPrintList",
		dataType:"json",
		success:function(res){
			var pre_print = res.result.data.prePrint,
				print = res.result.data.print,
				after_print = res.result.data.afterPrint,
				test = res.result.data.test,
				html1,
				html2,
				html3,
				html4;
				//印前
				for(let i=0;i<pre_print.length;i++){
					html1 += '<option data-id="'+pre_print[i].uuid+'">'+pre_print[i].pet_name+'</option>'
				}
				$("#prePrint").append(html1);
				//印刷
				for(let i=0;i<print.length;i++){
					html2 += '<option data-id="'+print[i].uuid+'">'+print[i].pet_name+'</option>'
				}
				$("#print").append(html2);
				//印后
				for(let i=0;i<after_print.length;i++){
					html3 += '<option data-id="'+after_print[i].uuid+'">'+after_print[i].pet_name+'</option>'
				}
				$("#afterPrint").append(html3);
				//质检
				for(let i=0;i<test.length;i++){
					html4 += '<option data-id="'+test[i].uuid+'">'+test[i].pet_name+'</option>'
				}
				$("#test").append(html4);
		}
	});
	//添加工序单
	$("#orderSubmit").on("click",function(){
		var order_id = id,
			preprint_id = $("#prePrint option:selected").attr("data-id"),
			print_id = $("#print option:selected").attr("data-id"),
			afterprint_id = $("#afterPrint option:selected").attr("data-id"),
			test_id = $("#test option:selected").attr("data-id");
		$.ajax({
			type:"post",
			url:"http://39.108.164.20/device/SysUser/InsOrderStep",
			dataType:"json",
			data:{
				order_id:order_id,
				preprint_id:preprint_id,
				print_id:print_id,
				afterprint_id:afterprint_id,
				test_id:test_id
			},
			success:function(res){
				alert(res.result.msg)
			}
		});	
	})
</script>